package com.anolesoft.yr.mbus.prod.base.mapper;

import com.anolesoft.yr.mbus.prod.base.dto.ProdBaseServiceDeleteDTO;
import com.anolesoft.yr.mbus.prod.base.dto.ProdBaseServiceSaveDTO;
import com.anolesoft.yr.mbus.prod.base.dto.ProdBaseServiceUpdateDTO;
import com.anolesoft.yr.mbus.prod.base.vo.ProdBaseServiceQueryNameVO;
import com.anolesoft.yr.mbus.prod.base.vo.ProdBaseServiceQueryVO;
import org.apache.ibatis.annotations.*;

import com.anolesoft.yr.mbus.prod.base.sql.ProdBaseServiceSQL;

import java.util.List;

@Mapper
public interface ProdBaseServiceMapper {

    //新增时查询服务项基础编号是否已经存在
    @Select(ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_BY_CODE)
    @Results(id = "queryProdBaseServiceByCode", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdBaseServiceByCode(String baseServiceCode);

    //新增时查询服务项基础名称是否已经存在
    @Select(ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_BY_NAME)
    @Results(id = "queryProdBaseServiceByName", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdBaseServiceByName(String baseServiceName);

    //新增服务项基础信息表
    @Insert(ProdBaseServiceSQL.SAVE_PROD_BASE_SERVICE)
    int saveProdBaseService(ProdBaseServiceSaveDTO prodBaseServiceDTO);

    //根据主键查询服务项基础唯一数据
    @Select(ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_BY_UID)
    @Results(id = "queryProdBaseServiceByUid", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "base_service_code", property = "baseServiceCode"),
            @Result(column = "base_service_name", property = "baseServiceName"),
            @Result(column = "import_type", property = "importType"),
            @Result(column = "is_timeliness", property = "isTimeliness"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    ProdBaseServiceQueryVO queryProdBaseServiceByUid(String uid);

    //根据主键查询服务项基础唯一数据
    @Select(ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_BY_UID2)
    @Results(id = "queryProdBaseServiceByUid2", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "base_service_code", property = "baseServiceCode"),
            @Result(column = "base_service_name", property = "baseServiceName"),
            @Result(column = "import_type", property = "importType"),
            @Result(column = "is_timeliness", property = "isTimeliness"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    ProdBaseServiceQueryVO queryProdBaseServiceByUid2(String uid);

    //修改时查询服务项基础编号是否已经存在
    @Select(ProdBaseServiceSQL.QUERY2_PROD_BASE_SERVICE_BY_CODE)
    @Results(id = "query2ProdBaseServiceByCode", value = {
            @Result(column = "count", property = "count")
    })
    int query2ProdBaseServiceByCode(@Param("baseServiceCode") String baseServiceCode, @Param("baseServiceCode2") String baseServiceCode2);

    //修改时查询服务项基础名称是否已经存在
    @Select(ProdBaseServiceSQL.QUERY2_PROD_BASE_SERVICE_BY_NAME)
    @Results(id = "query2ProdBaseServiceByName", value = {
            @Result(column = "count", property = "count")
    })
    int query2ProdBaseServiceByName(@Param("baseServiceName") String baseServiceName, @Param("baseServiceName2") String baseServiceName2);

    //修改服务项基础信息表
    @Update(ProdBaseServiceSQL.UPDATE_PROD_BASE_SERVICE)
    int updateProdBaseService(ProdBaseServiceUpdateDTO prodBaseServiceUpdateDTO);

    //删除服务项基础信息表
    @Update(ProdBaseServiceSQL.DELETE_PROD_BASE_SERVICE)
    int deleteProdBaseService(String objuid);

    //根据条件查询服务项基础数据条数
    @Select({ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_ALL_COUNT})
    @Results(id = "queryProdBaseServiceAllCount", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdBaseServiceAllCount(String baseServiceName);

    //根据条件查询服务项基础所有数据
    @Select({ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_ALL})
    @Results(id = "queryProdBaseServiceAll", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "base_service_code", property = "baseServiceCode"),
            @Result(column = "base_service_name", property = "baseServiceName"),
            @Result(column = "import_type", property = "importType"),
            @Result(column = "is_timeliness", property = "isTimeliness"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    List<ProdBaseServiceQueryVO> queryProdBaseServiceAll(@Param("baseServiceName") String baseServiceName, @Param("page") int page, @Param("limit") int limit);

    //查询基础服务项名称
    @Select(ProdBaseServiceSQL.QUERY_PROD_BASE_SERVICE_NAME)
    @Results(id = "queryBaseServiceName", value = {
            @Result(column = "objuid", property = "value"),
            @Result(column = "base_service_name", property = "text")
    })
    List<ProdBaseServiceQueryNameVO> queryBaseServiceName();

}
